#include "general.h"
#include "gauss-legendre.h"
#include "borwein.h"
#include "monte-carlo.h"

/* Interface gráfica do programa */

int main(int argc, char *argv[])
{
    mpf_t pi;
    long it;
    int time;
    int how, method;
    char file[50];

    if(argc != 3)
    {
        printf("Usage mode:\n");
        printf("\t%s [1: sequentially 2: concurrently] [1: gauss-legendre 2: borwein 3: monte-carlo]\n\n", argv[0]);
        printf("Example:\n\t%s 1 2\nwill execute the method Borwein sequentially.\n", argv[0]);
        return 1;
    }

    printf("Initializing precision...\n");

    mpf_set_default_prec(PREC);
    init_prec();
    mpf_init(pi);

    printf("Precision initialized.\n");

    how = atoi(argv[1]);
    method = atoi(argv[2]);

    printf("Calculating...\n");

    execute_method(how, method, pi, &it, &time, file);

    printf("Done!\n\n");
    printf("Number of iterations: %ld iterations\n", it);
    printf("Calculation time: %d seconds\n", time);
    printf("Output file: %s\n", file);

    clear_prec();
    mpf_clear(pi);

    return 0;
}
